Namespace.Use("UI.Object", function(ns) {
    //
    //  Imports.
    //
    var Inherit = Namespace.Import("Base.Inherit");
    var RenderCheckbox = Namespace.Import("UI.Theme.Checkbox.RenderCheckbox");

    //
    //  Global.
    //
    var cst_InitialFont = "bold 9pt Arial";

    //
    //  Classes.
    //
    var Checkbox = Polymorphic.Create(
        [Boolean, String, String],
        function(checked, text, font) {
            //  Let parent class initialize.
            ns.CanvasButton.call(this, function() {});

            //
            //  Members.
            //
            var last_checked = !checked;
            var last_font = null;
            var last_text = null;
            var out = this;

            //
            //  Private methods.
            //
            function RefreshRenderer() {
                var refresh = false;

                //  Update the "checked" property.
                if (last_checked != checked) {
                    last_checked = checked;
                    out.TriggerEvent("Changed", [checked]);
                    refresh = true;
                }

                //  Update the "font" property.
                if (last_font != font) {
                    last_font = font;
                    refresh = true;
                }

                //  Update the "text" property.
                if (last_text != text) {
                    last_text = text;
                    refresh = true;
                }

                //  Refresh the renderer.
                if (refresh == true) {
                    out.AccessRenderer(function(_ctx, _state) {
                        RenderCheckbox.call(out, _ctx, checked, _state, text, font);
                    });
                }
            }

            //
            //  Public methods.
            //
            this.AccessChecked = Polymorphic.Create(
                [],
                function() {
                    return checked;
                },
                [Boolean],
                function(new_checked) {
                    last_checked = checked;
                    checked = new_checked;
                    RefreshRenderer();
                }
            );
            this.AccessText = Polymorphic.Create(
                [],
                function() {
                    return text;
                },
                [String],
                function(new_text) {
                    last_text = text;
                    text = new_text;
                    RefreshRenderer();
                }
            );
            this.AccessFont = Polymorphic.Create(
                [],
                function() {
                    return font;
                },
                [String],
                function(new_font) {
                    last_font = font;
                    font = new_font;
                    RefreshRenderer();
                }
            );

            //
            //  Bind events.
            //
            this.RegisterEvent("Click", function() {
                out.AccessChecked(!checked);
            });

            //  Refresh immediately after created.
            RefreshRenderer();
        },
        [Boolean, String],
        function(checked, text) {
            this.constructor.call(this, checked, text, cst_InitialFont);
        },
        [String],
        function(text) {
            this.constructor.call(this, false, text);
        }
    );

    //  Inherit "Checkbox" from "CanvasButton".
    Inherit(Checkbox, ns.CanvasButton);

    //  Export public APIs / classes.
    Namespace.Export(ns, "Checkbox", Checkbox);
});